Register IAuthorizationHeaderProvider2 in DI#3927
Merged
neha-bhargava merged 3 commits intoJul 7, 2026
Merged
Conversation
bgavrilMS
approved these changes
Jul 7, 2026
DefaultAuthorizationHeaderProvider implements both IAuthorizationHeaderProvider and IAuthorizationHeaderProvider2, but only v1 was registered - so resolving v2 directly returned nothing (internal callers only worked because they cast). Register v2 as the same instance (mirroring how ITokenAcquisitionInternal is exposed off ITokenAcquisition) in both the singleton and scoped paths, and remove it on the lifetime-mismatch re-registration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bgavrilMS
force-pushed
the
nebharg/register-iauthorizationheaderprovider2
branch
from
July 7, 2026 11:20
62f62ca to
e31076a
Compare
gladjohn
approved these changes
Jul 7, 2026
* Register IAuthorizationHeaderProvider2 in DI DefaultAuthorizationHeaderProvider implements both IAuthorizationHeaderProvider and IAuthorizationHeaderProvider2, but only v1 was registered - so resolving v2 directly returned nothing (internal callers only worked because they cast). Register v2 as the same instance (mirroring how ITokenAcquisitionInternal is exposed off ITokenAcquisition) in both the singleton and scoped paths, and remove it on the lifetime-mismatch re-registration. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add GetAuthorizationHeaderProvider2() to OWIN controllers OWIN controllers already get a one-liner for the v1 IAuthorizationHeaderProvider; this adds the same convenience for IAuthorizationHeaderProvider2 on both ApiController and ControllerBase, resolving it from the OWIN TokenAcquirerFactory service provider. Depends on IAuthorizationHeaderProvider2 being registered in DI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
gladjohn
approved these changes
Jul 7, 2026
neha-bhargava
added a commit
that referenced
this pull request
Jul 10, 2026
Add the 4.13.0 changelog section (OWIN GetAuthorizationHeaderProvider2 #3928, IAuthorizationHeaderProvider2 DI registration #3927, MSAL 4.86.0 bump #3931), move the OWIN unshipped public API entries to shipped, and bump the dev version to 4.13.1. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Jul 10, 2026
Closed
Closed
Merged
This was referenced Jul 17, 2026
Open
Open
Closed
Closed
Open
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DefaultAuthorizationHeaderProviderimplements bothIAuthorizationHeaderProviderandIAuthorizationHeaderProvider2, butAddTokenAcquisitiononly registered v1. So resolvingIAuthorizationHeaderProvider2directly returned nothing - our own consumers (DownstreamApi, MicrosoftIdentityMessageHandler) only worked because they resolve v1 and cast.This registers v2 pointing at the same instance, using the same pattern we already use to expose
ITokenAcquisitionInternal/IConfidentialClientApplicationProvideroffITokenAcquisition:Tests: updated the two service-collection assertions, and added a Registers + a Resolves-to-same-instance test.